/**
 * 3. 调度方案
 */
Ext.define('Admin.view.waterOptimum.submodule.schedulingPlan',{
	extend:'Ext.grid.Panel',
	xtype:'woSchedulingPlan',
	//起别名
	alias:'woSchedulingPlan',
	require:[],
	user:[],
	userCLs:'big-100 small-100',
	border: false,
	store: {
		xtype:'store'
	},
	border: true,
	margin: '20 10 10 10',
	columns: [
		{ text: '时间', dataIndex: 'index1', minWidth: 100, align: 'center' },
		{text: '断面', columns:[{ text: '入流', dataIndex: 'col1_inflow', minWidth: 100, align: 'center', renderer:
				function customRound(value, record){
					if(value == null)return null;
					return Ext.util.Format.round(value, 0);
				}
		}]},
		{text: '区间', columns:[
			{ text: '分配', dataIndex: 'col2_allocate', minWidth: 100, align: 'center', renderer:
					function customRound(value, record){
						if(value == null)return null;
						return Ext.util.Format.number(value, '0.000');
					}
			},
			{ text: '供水', dataIndex: 'col2_supply', minWidth: 100, align: 'center', renderer:
					function customRound(value, record){
						if(value == null)return null;
						return Ext.util.Format.number(value, '0.000');
					}
			},
			{ text: '缺水', dataIndex: 'col2_lack', minWidth: 100, align: 'center', renderer:
					function customRound(value, record){
						if(value == null)return null;
						return Ext.util.Format.number(value, '0.000');
					}
			},
			{ text: '缺水率', dataIndex: 'col2_lackRate', minWidth: 100, align: 'center', renderer:
					function customRound(value, record){
						if(value == null)return null;
						return Ext.util.Format.round(value, 3);
					}
			}]},
		{text: '水库', columns:[
			{ text: '入流', dataIndex: 'col4_inflow', minWidth: 100, align: 'center', renderer:
					function customRound(value, record){
						if(value == null)return null;
						return Ext.util.Format.round(value, 0);
					}
			},
			{ text: '水位', dataIndex: 'col4_level', minWidth: 100, align: 'center', renderer:
					function customRound(value, record){
						if(value == null)return null;
						return Ext.util.Format.round(value, 2);
					}
			},
			{ text: '出流', dataIndex: 'col4_outflow', minWidth: 100, align: 'center', renderer:
					function customRound(value, record){
						if(value == null)return null;
						return Ext.util.Format.round(value, 0);
					}
			}]},
		{text: '区间2', columns:[
			{ text: '分配', dataIndex: 'col5_allocate', minWidth: 100, align: 'center', renderer:
					function customRound(value, record){
						if(value == null)return null;
						return Ext.util.Format.number(value, '0.000');
					}
			},
			{ text: '供水', dataIndex: 'col5_supply', minWidth: 100, align: 'center', renderer:
					function customRound(value, record){
						if(value == null)return null;
						return Ext.util.Format.number(value, '0.000');
					}
			},
			{ text: '缺水', dataIndex: 'col5_lack', minWidth: 100, align: 'center', renderer:
					function customRound(value, record){
						if(value == null)return null;
						return Ext.util.Format.number(value, '0.000');
					}
			},
			{ text: '缺水率', dataIndex: 'col5_lackRate', minWidth: 100, align: 'center', renderer:
					function customRound(value, record){
						if(value == null)return null;
						return Ext.util.Format.round(value, 3);
					}
			}]}
	],
	displayData:function(data){
	//	console.log(data);
		var heads = data.index1;
		var columns = new Array();
		columns.push({ text: '时间', dataIndex: 'index1', minWidth: 100, align: 'center'});
		for(var i=0;i<heads.length;i++){
			if(heads[i].type == "section"){
				columns.push({text: heads[i].text, columns:[{ text: '入流', dataIndex: heads[i].id+'_inflow', minWidth: 100, align: 'center', renderer:
						function customRound(value, record){
							if(value == null)return null;
							return Ext.util.Format.round(value, 0);
						}
				}]});
			}
			else if(heads[i].type == "usewater"){
				columns.push({text: heads[i].text, columns:[
					{ text: '分配', dataIndex: heads[i].id+'_allocate', minWidth: 100, align: 'center', renderer:
						function customRound(value, record){
							if(value == null)return null;
							return Ext.util.Format.number(value, '0.000');
						}
				},
				{ text: '供水', dataIndex: heads[i].id+'_supply', minWidth: 100, align: 'center', renderer:
						function customRound(value, record){
							if(value == null)return null;
							return Ext.util.Format.number(value, '0.000');
						}
				},
				{ text: '缺水', dataIndex: heads[i].id+'_lack', minWidth: 100, align: 'center', renderer:
						function customRound(value, record){
							if(value == null)return null;
							return Ext.util.Format.number(value, '0.000');
						}
				},
				{ text: '缺水率', dataIndex: heads[i].id+'_lackRate', minWidth: 100, align: 'center', renderer:
						function customRound(value, record){
							if(value == null)return null;
							return Ext.util.Format.round(value, 3);
						}
				}]});
			}
			else if(heads[i].type == "reservoir"){
				columns.push({text: heads[i].text, columns:[
					{ text: '入流', dataIndex: heads[i].id+'_inflow', minWidth: 100, align: 'center', renderer:
						function customRound(value, record){
							if(value == null)return null;
							return Ext.util.Format.round(value, 0);
						}
				},
				{ text: '水位', dataIndex: heads[i].id+'_level', minWidth: 100, align: 'center', renderer:
						function customRound(value, record){
							if(value == null)return null;
							return Ext.util.Format.round(value, 2);
						}
				},
				{ text: '出流', dataIndex: heads[i].id+'_outflow', minWidth: 100, align: 'center', renderer:
						function customRound(value, record){
							if(value == null)return null;
							return Ext.util.Format.round(value, 0);
						}
				}]});
			}
		}
		this.reconfigure(null, columns);
		this.getStore().setData(data.index2);
	}
});
